#include "../include/util.hpp"
#include <cassert>

using namespace easylog;
using namespace easylog::util;

void test_time()
{
    std::cout << "time: " << time::now() << std::endl;
    std::cout << time::format(time::now(), "%F %H:%M:%S") << std::endl;
    std::cout << time::format(time::now(), "%Y-%m-%d %H:%M:%S") << std::endl;
}

void test_color()
{
    std::cout << color::onclr(color_enum::none)         << "test none        " << color::offclr() << std::endl;
    std::cout << color::onclr(color_enum::black)        << "test black       " << color::offclr() << std::endl;
    std::cout << color::onclr(color_enum::light_black)  << "test light_black " << color::offclr() << std::endl;
    std::cout << color::onclr(color_enum::red)          << "test red         " << color::offclr() << std::endl;
    std::cout << color::onclr(color_enum::light_red)    << "test light_red   " << color::offclr() << std::endl;
    std::cout << color::onclr(color_enum::green)        << "test green       " << color::offclr() << std::endl;
    std::cout << color::onclr(color_enum::light_green)  << "test light_green " << color::offclr() << std::endl;
    std::cout << color::onclr(color_enum::yellow)       << "test yellow      " << color::offclr() << std::endl;
    std::cout << color::onclr(color_enum::light_yellow) << "test light_yellow" << color::offclr() << std::endl;
    std::cout << color::onclr(color_enum::blue)         << "test blue        " << color::offclr() << std::endl;
    std::cout << color::onclr(color_enum::light_blue)   << "test light_blue  " << color::offclr() << std::endl;
    std::cout << color::onclr(color_enum::purple)       << "test purple      " << color::offclr() << std::endl;
    std::cout << color::onclr(color_enum::light_purple) << "test light_purple" << color::offclr() << std::endl;
    std::cout << color::onclr(color_enum::cyan)         << "test cyan        " << color::offclr() << std::endl;
    std::cout << color::onclr(color_enum::light_cyan)   << "test light_cyan  " << color::offclr() << std::endl;
    std::cout << color::onclr(color_enum::white)        << "test white       " << color::offclr() << std::endl;
    std::cout << color::onclr(color_enum::light_white)  << "test light_white " << color::offclr() << std::endl;
}

void test_source_location()
{
    source_loc sl;

    std::cout << sl.file     << std::endl;
    std::cout << sl.function << std::endl;
    std::cout << sl.line     << std::endl;
    std::cout << sl.column   << std::endl;
}

void test_payload_format()
{
// #define easylog_LIB_FORMAT
    std::cout << payload::format("{} {} {}", 1, "test.cc", 222) << std::endl;
// #undef easylog_LIB_FORMAT
    std::cout << payload::format("%d %s %d", 1, "test.cc", 222) << std::endl;
}

#define test \
                5

int main()
{
    switch (test)
    {
        case 1: test_time();  break;
        case 2: test_color(); break;
        case 3: test_source_location(); break;
        case 4: test_payload_format(); break;
        default: assert(false);
    }

    return 0;
}
